<template>
  <div class="attr-item block">
    <div class="iconfont tac" :class="icon">
      <span>{{text}}</span>
    </div>
    <div>
      <input type="text" :value="modelValue" @input="change" />
    </div>
  </div>
</template>
<script>
import { reactive, toRefs } from 'vue'

const iconType = {
  'health': 'icon-health',
  'strength': 'icon-attack',
  'speed': 'icon-speed',
  'defense': 'icon-defense',
  'movement': 'icon-Boot',
  'power': 'icon-intelligence',
  'baseExp': 'icon-ldc-intelligence',
  'baseMoney': 'icon-coin1',
  'expPerLevel': 'icon-ldc-intelligence',
  'MoneyPerLevel': 'icon-coin1',
}

export default {
  props: {
    type: {
      type: String,
      default: '',
    },
    modelValue: {
      type: Number,
      default: 0
    }
  },
  setup(props, context) {
    // console.log(props);
    const attrNameMap = {
      health: '生命', strength: '强度', defense: '防卫', speed: '速度', power: '精神', movement: '移动',
      baseExp : '经验',expPerLevel:'递增',baseMoney:'金钱',MoneyPerLevel:'递增'
    }
    const state = reactive({
      icon: iconType[props.type],
      text: attrNameMap[props.type]
    })

    const change = (event) => {
      context.emit('update:modelValue', parseInt(event.target.value))
    }

    return {
      ...toRefs(state),
      change
    }
  },
}
</script>
<style lang="less" scoped>
  @import '../../../theme.less';
.attr-item {
  width: 100px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 5px;
}
input[type="text"] {
  width: 50px;
  text-align: center;
  padding: 0;
  // height: 30px;
  margin-left: 10px;
}
.iconfont {
  color: @theme-line;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
</style>